wayland: Avoid using uninitialized memory
authorMatthias Clasen <mclasen@redhat.com>
Thu, 18 Apr 2019 14:22:48 +0000 (14:22 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 18 Apr 2019 14:27:00 +0000 (14:27 +0000)
_gdk_wayland_cursor_get_buffer was not initializing
its out variables in the 'not found' case. This
was showing up in protocol traces as garbage hotspots
being sent to the compositor.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1328
gdk/wayland/gdkcursor-wayland.c

index ec6c19ca634e770f5a720ba67296394c25a07f76..91d80e301809486df83a296a99604e05f5ec517b 100644 (file)
@@ -169,14 +169,7 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
       struct wl_cursor *c;
 
       if (g_str_equal (gdk_cursor_get_name (cursor), "none"))
-        {
-          *hotspot_x = 0;
-          *hotspot_y = 0;
-          *width = 0;
-          *height = 0;
-          *scale = 1;
-          return NULL;
-        }
+        goto none;
 
       c = gdk_wayland_cursor_load_for_name (display,
                                             _gdk_wayland_display_get_scaled_cursor_theme (display, desired_scale),
@@ -250,6 +243,13 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
                                            width, height,
                                            scale);
 
+none:
+  *hotspot_x = 0;
+  *hotspot_y = 0;
+  *width = 0;
+  *height = 0;
+  *scale = 1;
+
   return NULL;
 }